package com.resou.reader.discovery.choicenes.adapter;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.R;
import com.resou.reader.api.entry.BookDetailBean;
import com.resou.reader.api.entry.ChoiceneBookListBean;
import com.resou.reader.discovery.bookdetail.BookListActivity;

import java.util.List;

/**
 * Author: 萤火虫
 * E-mail:  Allensuns@163.com
 * Description: 精选书单适配器
 * CreateTime: 2019-03 -22
 **/
public class ChoiceneBookAdapter extends BaseQuickAdapter<ChoiceneBookListBean.UnRecommendBean.BookListBean, BaseViewHolder> {
    public ChoiceneBookAdapter(int layoutResId, @Nullable List<ChoiceneBookListBean.UnRecommendBean.BookListBean> data) {
        super(layoutResId, data);
    }

    public ChoiceneBookAdapter(@Nullable List<ChoiceneBookListBean.UnRecommendBean.BookListBean> data) {
        super(data);
    }

    public ChoiceneBookAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, ChoiceneBookListBean.UnRecommendBean.BookListBean item) {
        try {
            helper.addOnClickListener(R.id.llContent);
            helper.setText(R.id.tvTitle, item.getBookListName() + "");
            helper.setText(R.id.tvDes, item.getBookListRecommend() + "");
            helper.setText(R.id.tvCollection, item.getBookCount() + "本 | " + item.getCollectionCount() + "收藏");
            String[] urls = item.getBookListUrl().split(",");
            Glide.with(mContext).load(urls[0] == null ? "" : urls[0]).into((ImageView) helper.getView(R.id.ivPic1));
            Glide.with(mContext).load(urls[1] == null ? "" : urls[1]).into((ImageView) helper.getView(R.id.ivPic2));
            Glide.with(mContext).load(urls[2] == null ? "" : urls[2]).into((ImageView) helper.getView(R.id.ivPic3));
        } catch (Exception e) {
            Log.i(TAG, "convert: " + e.getMessage());
        }
    }
}
